
"""
    定义函数，在终端中打印一维列表
"""
def circle(list_target):
    for item in list_target:
        print(item)

list01 = [5,546,6,56,76]
circle(list01)
list02 = [7,6,879,9,909,]
circle(list02)

def print_jz(number, character):
    for row in range(number):
        if row ==0 or row == number-1:
            print(character * number)
        else:
            print(character+""+" " * (number -2)+""+character %())

# number = int(input("请输入整数："))
# char = input("请输入一个符号:")
# print_jz(number,char)

# 返回值
def count_cure_rate(cure,confirmed):
    return cure / confirmed *100

# confirmed = int(input("请输入确诊人数："))
# cure = int(input("请输入治愈人数"))
# cure_rate = count_cure_rate(cure,confirmed)
# print("治愈比例为："+str(cure_rate)+"%")

def count_jin_liang(total_liang):
    jin = total_liang //16
    liang = total_liang % 16
    return jin,liang

total_liang = 105.9
tuple01 = count_jin_liang(total_liang)
print(f"总共{tuple01[0]}斤，{tuple01[1]}两")
# 星号元组形参：将多个实参合并为一个元组不支持关键字实参
def func01(*p):
    print(p)
# 双星号字典形参：将多个关键字实参合并为一个字典
def func02(**p):
    print(p)

func01(1,2,3)
func02(a=1,b=2)

# 练习：定义函数，数值累乘
# *p 为星号元组形参
# **p 为星号字典形参
def total_mulp(*p):
    total = 1
    for i in p:
        total *= i
    print(total)
# 让调用者不必自行构建容器存储多个数据
# 而是由Python解释器自动构建元组包装多个数据
total_mulp(42,54,56,65,76)

"""
函数参数：
    实际参数
        位置实参
        关键字实参
    形式参数
        位置形参
        默认形参
        星号元组形参
        爽型号字典形参
"""
# 命名关键字形参：要求实参必须是关键字实参
def func01(*args,p):
    print(args)
    print(p)

# 命名关键字形参+默认形参
def func02(*args,p=0):
    print(args)
    print(p)
# 适用性，当调用函数不能确定实参时，需要由第三方构建容器决定数据是
#序列实参：拆序列，传元素，按顺序对应
list01 = [10,20,30]
func01(*list01)
#字典实参：拆字典，传元素，按名称对应
dict01={"p2":2,"p1":1,"p3":3}
func02(**dict01)